package com.googlecode.animator.data.materials
{
	import com.googlecode.animator.data.IValueObject;
	
	public class FileAssetMaterialVO extends MaterialVO
	{
		public static const TYPE:String = "FileAssetMaterial";
		
		public var filePath:String;
		
		public var isRelative:Boolean = false;
		
		public var width:uint = 320;
		
		public var height:uint = 240;
	
		override public function clone(src:* = null):IValueObject
		{
			if(src == null)
			{
				src = super.clone(new FileAssetMaterialVO());
			}else
			{
				src = super.clone(src);
			}
			
			(src as FileAssetMaterialVO).filePath = this.filePath;
			(src as FileAssetMaterialVO).isRelative = this.isRelative;
			(src as FileAssetMaterialVO).width = this.width;
			(src as FileAssetMaterialVO).height = this.height;
			
			return (src as FileAssetMaterialVO);
		}
		
		override public function toXML(src:XML = null):XML
		{
			if(src == null)
			{
				src = super.toXML();
				
			}else
			{
				src = super.toXML(src);
			}
			
			src.appendChild(<filePath isRelative={this.isRelative}>{this.filePath}</filePath>);
			src.appendChild(<width>{this.width}</width>);
			src.appendChild(<height>{this.height}</height>);

			return src;
		}
		
		override public function fromXML(src:XML):void
		{
			super.fromXML(src);
			
			this.filePath = src.filePath;
			this.isRelative = src.filePath.@isRelative == "true" ? true : false;
			this.width = src.width;
			this.height = src.height;
			
		}
	}
}